const webpack = require('webpack')
const path = require('path')
const resolve = dir => path.resolve(__dirname, dir)
module.exports = {
  devServer: {
    before(app) {
    }
    // 'proxy': {
    //   '/api': {
    //     'target': 'http://ustbhuangyi.com/sell/api',
    //     'changeOrigin': true,
    //     'ws': true,
    //     'pathRewrite': {
    //       '^/api': ''
    //     }
    //   }
    // }
  },

  chainWebpack: config => {
    config.resolve.alias
      .set('components', resolve('src/components'))
      .set('common', resolve('src/common'))
      .set('views', resolve('src/views'))
      .set('base', resolve('src/base'))
      .set('mixins', resolve('src/mixins'))
      .set('api', resolve('src/api'))
    config
      .plugin('context')
      .use(webpack.ContextReplacementPlugin, [/moment[/\\]locale$/, /zh-cn/])
  },

  configureWebpack: config => {
    config.resolve.extensions.push('.styl')
  },

  css: {
    loaderOptions: {
      stylus: {
        'resolve url': true,
        import: [
          './src/theme'
        ]
      }
    }
  },

  pluginOptions: {
    'cube-ui': {
      postCompile: true,
      theme: true
    }
  }
}
